<template>
  <scroll :scrollX="true" ref="scroll" class="scroll-wrapper">
    <div v-for="(item, index) in showDate" :key="+item" class="banner-item scroll-item">
      <span @click="getIndex(index)" :class="{ active: index === currentIndex }">{{ item | today }}</span>
    </div>
  </scroll>
</template>

<script>
import Scroll from 'components/common/scroll/Scroll.vue'
export default {
  components: { Scroll },
  name: 'BannerTime',
  props: ['showDate'],
  data() {
    return {
      currentIndex: 0
    }
  },
  updated() {
    this.init()
  },
  methods: {
    getIndex(index) {
      this.currentIndex = index
      this.$emit('getPlayDate', index)
    },
    init() {
      this.$refs.scroll.refresh()
    }
  }
}
</script>

<style lang="scss" scoped>
.scroll-wrapper {
  width: 90%;
  white-space: nowrap;
  overflow: hidden;
  .scroll-item {
    padding: 0 0.15rem;
    line-height: 0.49rem;
    flex-shrink: 0;
    display: inline-block;
  }
}
.active {
  border-bottom: 2px solid #ff5f16;
  padding: 0.13rem 0;
  color: #ff5f16;
}

::v-deep .scroll-content {
  display: inline-block;
}
</style>